<@admin.header title="分配权限">
<script type="text/javascript">
	App.ns("PR");
	PR.form = new App.common.Form();
	PR.dialog = new App.common.dialog();
	
	PR.submit = function(){
		var pers = [];
		$("input[type='checkbox'][pid=0]").each(function(){
			if(this.checked){
				pers.push(this.value);
			}else{
				$("input[type='checkbox'][pid="+this.value+"]").each(function(){
					if(this.checked)
						pers.push(this.value);
				});
			}
		});
		
		$.ajax({
			url: window.location.href,
			data:{
				"roleId":$("#roleId").val(),
				'ids':pers
			},
			type:'post',
			dataType:'json',
			success:function(ret){
				PR.dialog.confirm("保存成功，现在可以关闭此窗口了",function(){
					window.close();
				});
			}
		});
	}
	
    $(document).ready(function(){
    	
    });
</script>
<style>
	.role dl {border:1px solid #d7d7d7;padding:10px;margin-bottom:10px;}
	.role dt label {font-size:15px; font-weight:bold;}
	.role dd {margin-top:10px;}
	.role dd label {margin-right:50px;}
	.hide {display:none;}
</style>
</@admin.header>
    <body style="min-width:750px;">
        <div class="place hide">
            <span>位置：</span>
            <ul class="placeul">
                <li>
                    <a href="#">首页</a>
                </li>
                <li>
                    <a href="#">系统角色管理</a>
                </li>
                <li>
                    <a href="#">角色权限分配</a>
                </li>
            </ul>
        </div>
        <div class="rightinfo role">
			<div class="formtitle" style="margin-bottom:10px;">
	            <span>${role.name}分配的权限</span>
	        </div>
			<input type="hidden" id="roleId" value="${role.id}" />
        	<#list permissionList as p>
			<dl>
        		<dt>
        			<label>
        				<input type="checkbox" onchange="PR.form.checkToggle('p_${p.id}',this);" <#if permissionStr?contains(','+p.id+',')>checked="checked"<#else></#if> value="${p.id}" 
							pid="<#if p.parent??>${p.parent.id}<#else>0</#if>"/>
						${p.name}
        			</label>
        		</dt>
				<dd>
				<#list p.children as pc>
					<label title="${pc.description!''}">
        				<input name="p_${p.id}" type="checkbox" 
							<#if permissionStr?contains(','+p.id+',') || permissionStr?contains(','+pc.id+',')>
							checked="checked"
							<#else>
							</#if> 
							value="${pc.id}"
							pid="${p.id}"/>
						${pc.name}
        			</label>
				</#list>
				</dd>
			</dl>
			</#list>
			
			<ul class="forminfo">
				<li>
	                <label class="field">
	                    &nbsp;
	                </label>
	                <input type="button" onclick="PR.submit();" class="btn" value="确认保存"/>
	            </li>
			</ul>
        </div>
    </body>
</html>